# -*- coding: utf-8 -*-
# @Time : 2021/7/4 22:00
# @Author : feimaotuiya
# @File : page_ecshop_front_my_remark.py
# @Project : ecshop-gitee
from selenium.webdriver.common.by import By


class PageEshopFrontmyremark():
    def __init__(self, driver):
        self.driver = driver
        # 元素定位
        self.loc_front_my_account = (By.XPATH, '/html/body/div[1]/div/div/a[1]')
        self.loc_front_my_remark = (By.XPATH, '/html/body/div[7]/div[1]/div/div/div/div/a[11]')
        self.loc_front_my_remark_accert = (By.XPATH, '/html/body/div[7]/div[2]/div/div/div/div[2]/b')
        self.loc_front_my_leave_word = (By.XPATH, '/html/body/div[7]/div[1]/div/div/div/div/a[6]')
        self.loc_fron_leave_word_theme = (By.NAME, 'msg_title')
        self.loc_fron_leave_word_content = (By.NAME, 'msg_content')
        self.loc_fron_leave_word_submit = (
            By.XPATH, '/html/body/div[7]/div[2]/div/div/div/form/table/tbody/tr[5]/td[2]/input[2]')
        self.loc_back_cat_leave_word = (By.XPATH, '//div[@id="listDiv"]/table[1]/tbody/tr[2]/td[3]')

    def front_my_account(self):
        self.driver.find_element(*self.loc_front_my_account).click()

    def front_my_remark(self):
        self.driver.find_element(*self.loc_front_my_remark).click()

    def front_my_remark_accert(self):
        actual = self.driver.find_element(*self.loc_front_my_remark_accert).text
        return actual

    def front_my_leave_word(self):
        self.driver.find_element(*self.loc_front_my_leave_word).click()

    def front_leave_word_theme(self, theme):
        self.driver.find_element(*self.loc_fron_leave_word_theme).send_keys(theme)

    def front_leave_word_content(self, content):
        self.driver.find_element(*self.loc_fron_leave_word_content).send_keys(content)

    def front_leave_word_submit(self):
        self.driver.find_element(*self.loc_fron_leave_word_submit).click()

    def back_cat_leave_word(self):
        actual = self.driver.find_element(*self.loc_back_cat_leave_word).text
        return actual

    def cat_my_remark(self):
        self.front_my_account()
        self.front_my_remark()
        actual = self.front_my_remark_accert()
        return actual

    def add_leave_word(self, theme, content):
        self.front_my_account()
        self.front_my_leave_word()
        self.front_leave_word_theme(theme)
        self.front_leave_word_content(content)
        self.front_leave_word_submit()
